﻿using System;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace HYRElectric.EquipmentPlace
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdMoveEmergencyLights : YJKCommandManual
	{
		protected override Result YJKExcute(ExternalCommandData cmdData, ref string message, ElementSet elements)
		{
			using (DlgMoveEmergencyLights dlgMoveEmergencyLights = new DlgMoveEmergencyLights())
			{
				DialogResult dialogResult = dlgMoveEmergencyLights.ShowDialog();
				if (dialogResult == DialogResult.Cancel)
				{
					return Autodesk.Revit.UI.Result.Succeeded;
				}
				if (dialogResult == DialogResult.OK)
				{
					EquipmentModifyer equipmentModifyer = new EquipmentModifyer(cmdData);
					equipmentModifyer.equipmentType = EquipmentType.ET_EmergencyLight;
					equipmentModifyer.VDistance = dlgMoveEmergencyLights.Distance;
					if (dlgMoveEmergencyLights.operateType == OperateType.OT_Select)
					{
						return equipmentModifyer.FindSingle();
					}
					if (dlgMoveEmergencyLights.operateType == OperateType.OT_CurrentView)
					{
                        return equipmentModifyer.FindCurrentFloor(BuiltInCategory.OST_LightingFixtures);
					}
                    return equipmentModifyer.FindDocument(BuiltInCategory.OST_LightingFixtures);
				}
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
